home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / ctan.c < prev    next >
C/C++ Source or Header  |  1991-09-24  |  2KB  |  90 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    ctan   complex double precision tangent
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    ctan
  29.  *    complex functions
  30.  *    machine independent functions
  31.  *    math libraries
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Computes double precision complex tangent of a double
  36.  *    precision complex argument.
  37.  *
  38.  *  USAGE
  39.  *
  40.  *    COMPLEX ctan (z)
  41.  *    COMPLEX z;
  42.  *
  43.  *  PROGRAMMER
  44.  *
  45.  *    Fred Fish
  46.  *    Tempe, Az 85281
  47.  *    (602) 966-8871
  48.  *
  49.  *  INTERNALS
  50.  *
  51.  *    Computes complex tangent of z = x + j y from:
  52.  *
  53.  *        1.    Compute ccos(z)
  54.  *
  55.  *        2.    If ccos(z) = 0 + j0 then the
  56.  *            result is MAX_POS_DBLF + j0
  57.  *
  58.  *        3.    Else ctan(z) = csin(z) / ccos(z)
  59.  *
  60.  */
  61.  
  62. #include <stdio.h>
  63. #include <pmluser.h>
  64. #include "pml.h"
  65.  
  66.  
  67. COMPLEX ctan (z)
  68. COMPLEX z;
  69. {
  70.     COMPLEX ccosz;
  71.     extern COMPLEX ccos (), csin (), cdiv ();
  72.  
  73.     ENTER ("ctan");
  74.     DEBUG4 ("ctanin", "arg %le %le", z.real, z.imag);
  75.     ccosz = ccos (z);
  76.     if (ccosz.real == 0.0 && ccosz.imag == 0.0) {
  77. /*****
  78.     z.real = MAX_POS_DBLF;
  79. ******/
  80.     z.real = 0.0;        /* TERRIBLY WRONG! */
  81.     z.imag = 0.0;
  82.     } else {
  83.     z = csin (z);
  84.     z = cdiv (z, ccosz);
  85.     }
  86.     DEBUG4 ("ctanout", "result %le %le", z.real, z.imag);
  87.     LEAVE ();
  88.     return (z);
  89. }
  90.